package com.warm.base.design.c_singleton;

/**
 * @Date: 2019/11/21 16:40
 * @Author: LChuang
 * @Description:
 */
public class StaticInnerClassSingleton {

    /**
     *  3. 静态内部类 -- 线程安全
     *  在调用getInstance()是才加载,达到懒加载效果
     *  缺点: 可能存在反射攻击或者序列话攻击 -- 实现序列化接口
     */
    private static class SingletonPlaneHolder{
        private static StaticInnerClassSingleton INSTANCE = new StaticInnerClassSingleton();
    }

    private StaticInnerClassSingleton(){}

    public static StaticInnerClassSingleton getInstance(){
        return SingletonPlaneHolder.INSTANCE;
    }
}
